package com.wjc.train.business.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wjc.train.business.req.SkTokenQueryReq;
import com.wjc.train.business.req.SkTokenSaveReq;
import com.wjc.train.business.resp.SkTokenQueryResp;
import com.wjc.train.business.service.ISkTokenService;
import com.wjc.train.common.resp.CommonResp;
import com.wjc.train.common.untils.PageUtil;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Guessed
 * @since 2023-09-01
 */
@RestController
@Validated
@RequestMapping("/admin/skToken")
public class SkTokenController {

    @Resource
    private ISkTokenService sktokenService;

    @PostMapping("/save")
    public CommonResp save(@RequestBody @Valid SkTokenSaveReq sktokenSaveReq){
        sktokenService.save(sktokenSaveReq);
        return CommonResp.success();
    }

    @PostMapping("/query-list")
    public CommonResp save(@RequestBody SkTokenQueryReq sktokenQueryReq){
        IPage<SkTokenQueryResp> iPage =
        sktokenService.queryList(PageUtil.getPage(sktokenQueryReq.getQueryPage()), sktokenQueryReq);
        return CommonResp.success(new PageUtil(iPage));
    }

    @DeleteMapping ("/delete/{id}")
    public CommonResp delete(@PathVariable Long id){
        sktokenService.delete(id);
        return CommonResp.success();
    }


}


